//
//  GKZYBatchQueryCell.m
//  GKZYAid
//
//  Created by tony on 16/2/29.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYBatchQueryCell.h"
#import "MyDefine.h"
#import "GKZYBatchQueryModel.h"
#import "GKZYBatchScoreView.h"

@interface GKZYBatchQueryCell ()

@end

@implementation GKZYBatchQueryCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
    }
    return self;
}




-(void)configureTheCellWithScienceArray:(NSMutableArray *)scienceArray andArtsArray:(NSMutableArray *)artsArray{

    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(KmainScreenBounds.size.width*0.05, KmainScreenBounds.size.height*0.05, KmainScreenBounds.size.width *0.9, KmainScreenBounds.size.height*0.05)];
        label1.textColor = [UIColor orangeColor];
        label1.text = @"理科";
        label1.font = [UIFont systemFontOfSize:20];
        [self addSubview:label1];
        
        self.frame = CGRectMake(0, 0, KmainScreenBounds.size.width, KmainScreenBounds.size.height);
        
        GKZYBatchScoreView *batch1 = [[GKZYBatchScoreView alloc]initWithFrame:CGRectMake(CGRectGetMinX(label1.frame), CGRectGetMaxY(label1.frame)+KmainScreenBounds.size.height*0.02, CGRectGetWidth(label1.frame), KmainScreenBounds.size.height *0.05)];
        batch1.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.1];
        [batch1 configureTheVeiwWithYear:@"年份" andFirst:@"第一批" Second:@"第二批" Third:@"第三批" andTextColor:[UIColor blackColor]];
        [self addSubview:batch1];
        
        for (int i = 0; i<5; i++) {
        
            GKZYBatchScoreView *scoreItem = [[GKZYBatchScoreView alloc]init];
            scoreItem.frame = CGRectMake(CGRectGetMinX(batch1.frame), CGRectGetMaxY(batch1.frame)+CGRectGetHeight(batch1.frame)*(i), CGRectGetWidth(batch1.frame), CGRectGetHeight(batch1.frame));
            
            if (i%2!=0) {
                scoreItem.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.1];
            }
            
            if (scienceArray.count != 0) {
                GKZYBatchQueryModel *model = scienceArray[i];
                NSArray *array = model.lines;
                NSString *string1 = [NSString stringWithFormat:@"%@",array[0]];
                NSString *string2 = [NSString stringWithFormat:@"%@",array[1]];
                if ([string2 isEqualToString:@"-1"]) {
                    string2 = @"--";
                }
                NSString *string3 = [NSString stringWithFormat:@"%@",array[2]];
                if ([string3 isEqualToString:@"-1"]) {
                    string3 = @"--";
                }
                if (i == 0) {
                    [scoreItem configureTheVeiwWithYear:model.years andFirst:string1 Second:string2 Third:string3 andTextColor:[UIColor orangeColor]];
                }else{
                 [scoreItem configureTheVeiwWithYear:model.years andFirst:string1 Second:string2 Third:string3 andTextColor:[UIColor blackColor]];
                }
            }
            
            [self addSubview:scoreItem];
        }
            UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(KmainScreenBounds.size.width*0.05, KmainScreenBounds.size.height*0.45, KmainScreenBounds.size.width *0.9, KmainScreenBounds.size.height*0.05)];
            label2.textColor = [UIColor orangeColor];
            label2.text = @"文科";
            label2.font = [UIFont systemFontOfSize:20];
            [self addSubview:label2];
            
            GKZYBatchScoreView *batch2 = [[GKZYBatchScoreView alloc]initWithFrame:CGRectMake(CGRectGetMinX(label2.frame), CGRectGetMaxY(label2.frame)+KmainScreenBounds.size.height*0.02, CGRectGetWidth(label2.frame), KmainScreenBounds.size.height *0.05)];
            batch2.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.1];

            [batch2 configureTheVeiwWithYear:@"年份" andFirst:@"第一批" Second:@"第二批" Third:@"第三批" andTextColor:[UIColor blackColor]];
            [self addSubview:batch2];
            
            for (int i = 0; i<5; i++) {
                
                GKZYBatchScoreView *scoreItem = [[GKZYBatchScoreView alloc]init];
                scoreItem.frame = CGRectMake(CGRectGetMinX(batch2.frame), CGRectGetMaxY(batch2.frame)+CGRectGetHeight(batch2.frame)*(i), CGRectGetWidth(batch2.frame), CGRectGetHeight(batch2.frame));
                
                if (i%2!=0) {
                    scoreItem.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.1];
                }
                
                if (scienceArray.count != 0) {
                    GKZYBatchQueryModel *model = artsArray[i];
                    NSArray *array = model.lines;
                    NSString *string1 = [NSString stringWithFormat:@"%@",array[0]];
                    NSString *string2 = [NSString stringWithFormat:@"%@",array[1]];
                    if ([string2 isEqualToString:@"-1"]) {
                        string2 = @"--";
                    }
                    NSString *string3 = [NSString stringWithFormat:@"%@",array[2]];
                    if ([string3 isEqualToString:@"-1"]) {
                        string3 = @"--";
                    }
                    if (i == 0) {
                        [scoreItem configureTheVeiwWithYear:model.years andFirst:string1 Second:string2 Third:string3 andTextColor:[UIColor orangeColor]];
                    }else{
                        [scoreItem configureTheVeiwWithYear:model.years andFirst:string1 Second:string2 Third:string3 andTextColor:[UIColor blackColor]];
                    }

                }
                [self addSubview:scoreItem];
            }
    
    self.frame = CGRectMake(0, 0, KmainScreenBounds.size.width, KmainScreenBounds.size.height*0.85);
    
}





@end
